package qeb.handheldmedical.adapter;

import org.json.JSONArray;
import org.json.JSONObject;

import qeb.handheldmedical.R;
import qeb.handheldmedical.adapter.ExamItemAdapter.ViewHolder;
import qeb.handheldmedical.model.ExamItem;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

/**
 * @author 作者(dugaoyi) E-mail:dugaoyi@163.com
 * @version 创建时间：2016年8月31日 下午5:24:22
 * @declaration 考试成功设备器
 */
public class ExamScoresItemAdapter extends BaseAdapter {

	private static final String TAG = "mExamScoresJsonArray";
	// private ImageSwitcher mImageLoader;
	private int mCount;
	private Context mContext;
	private JSONArray mExamScoresJsonArray = null;

	public ExamScoresItemAdapter(int count, Context context,
			JSONArray examScoresJsonArray) {
		this.mCount = count;
		this.mContext = context;
		this.mExamScoresJsonArray = examScoresJsonArray;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mCount;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewholder = null;
		convertView = LayoutInflater.from(mContext).inflate(
				R.layout.adapter_exam_scores_item, null);
		viewholder = new ViewHolder();
		viewholder.txtExamTime = (TextView) convertView
				.findViewById(R.id.txtExamTime);
		viewholder.txtExamScores = (TextView) convertView
				.findViewById(R.id.txtExamScores);
		convertView.setTag(viewholder);
		try {
			JSONObject xt = mExamScoresJsonArray.getJSONObject(position);
			if (xt != null) {
				viewholder.txtExamTime.setText(xt.getString("EXAMTIME"));
				viewholder.txtExamScores.setText("分数："+xt.getString("SCORES"));
			}
		} catch (Exception e) {
			// TODO: handle exception
			Log.e(TAG, e.toString());
		}
		return convertView;
	}

	static class ViewHolder {
		TextView txtExamTime;
		TextView txtExamScores;
	}

}
